package me.android.library.utils.android.wifi;

import android.net.wifi.WifiManager;
import android.net.wifi.WifiNetworkSuggestion;
import android.os.Build;

import androidx.annotation.RequiresApi;

import java.util.List;
import java.util.Objects;

import me.android.library.utils.android.SystemServiceUtil;

@RequiresApi(api = Build.VERSION_CODES.R)
public interface WifiConfig {

    default WifiManager getWifiManager() {
        return SystemServiceUtil.getWifiManager();
    }

    default List<WifiNetworkSuggestion> getWifiNetworkSuggestion() {
        return getWifiManager().getNetworkSuggestions();
    }

    default boolean isNetworkSuggested(String ssid) {
        List<WifiNetworkSuggestion> suggestions = getWifiNetworkSuggestion();
        if (suggestions != null) {
            return suggestions.stream().anyMatch(net -> Objects.equals(net.getSsid(), ssid));
        }
        return false;
    }
}
